<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #box{
      width: 200px;
      height: 200px;
      background-color: rgb(113, 158, 103);
      margin: 20px auto;
    }
  </style>
</head>
<body>
  <button>隐藏</button>
  <div id="box"></div>
  <script>
    var btn = document.querySelector('button');
    var box = document.querySelector('#box');
    btn.onclick = function(){
      if(!this.onOff){
        box.style.display = 'none';
        this.innerHTML = '显示';
        this.onOff = !this.onOff;
      }else{
        box.style.display = 'block';
        this.innerHTML = '隐藏';
        this.onOff = !this.onOff;
      }
    }
  </script>
</body>
</html>